<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增教师信息')" />
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-teacher-add">
            <div class="form-group col-sm-5">
                <label class="col-sm-4 control-label">姓名：</label>
                <div class="col-sm-8">
                    <input name="name" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">性别：</label>
                <div class="col-sm-8">
                    <div class="radio-box" style="height: 34px;" th:each="dict : ${@dict.getType('edu_sex')}">
                        <input type="radio" th:id="${'sex_' + dict.id}" name="sex" th:value="${dict.itemValue}" th:checked="${dict.isDefault == 'Y' ? true : false}">
                        <label th:for="${'sex_' + dict.id}" th:text="${dict.itemText}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group col-sm-5">
                <label class="col-sm-4 control-label">民族：</label>
                <div class="col-sm-8">
                    <input name="national" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">出生日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="birthday" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group col-sm-5">
                <label class="col-sm-4 control-label">职务：</label>
                <div class="col-sm-8">
                    <select name="position" class="form-control m-b" th:with="type=${@dict.getType('edu_position')}">
                        <option th:each="dict : ${type}" th:text="${dict.itemText}" th:value="${dict.itemValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">学历：</label>
                <div class="col-sm-8">
                    <select name="educationBackground" class="form-control m-b" th:with="type=${@dict.getType('edu_background')}">
                        <option th:each="dict : ${type}" th:text="${dict.itemText}" th:value="${dict.itemValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">参加工作：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="workTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">身份证号：</label>
                <div class="col-sm-8">
                    <input name="idNumber" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">户口所在地：</label>
                <div class="col-sm-8">
                    <input name="residenceLocation" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">手机号码：</label>
                <div class="col-sm-8">
                    <input name="mobilePhone" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">办公座机：</label>
                <div class="col-sm-8">
                    <input name="officePhone" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">所在学校：</label>
                <div class="col-sm-8">
                    <input name="school" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">任教学科：</label>
                <div class="col-sm-8">
                    <input name="teachSubjects" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">任教年级：</label>
                <div class="col-sm-8">
                    <input name="teacheGrade" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">任教班级：</label>
                <div class="col-sm-8">
                    <input name="teacheClass" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-6">
                <label class="col-sm-4 control-label">政治面貌：</label>
                <div class="col-sm-8">
                    <input name="politicsStatus" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group col-sm-12">
                <label class="col-sm-2 control-label" style="width: 16%;">家庭住址：</label>
                <div class="col-sm-9" style="width: 80%;">
                    <input name="familyLocation" class="form-control" type="text">
                </div>
            </div>
            <input name="photo" type="hidden">
            <div class="form-group" style="position:absolute; top:20px; right:25px;">
                <div class="fileinput fileinput-new" data-provides="fileinput" style="position: relative; width:140px; height:160px;">
                    <div class="fileinput-new thumbnail" style="width: 130px; height: 130px;">
                        <img th:src="@{/res/img/touxiang.png}">
                    </div>
                    <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 130px;"></div>
                    <div style="text-align: center;">
                        <span class="btn btn-white btn-file">
                            <span class="fileinput-new">选择图片</span>
                            <span class="fileinput-exists">更改</span>
                            <input type="file" id="williamYe">
                        </span>
                        <a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                    </div>
                </div>
            </div>
        </form>


    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "education/teacher"
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#form-teacher-add").validate({
            rules: {
                idNumber: {
                    required: true,
                    isIdentity:true
                }
            },
            messages: {
                idNumber: {
                    required: icon + "请输入您的身份证号",
                    isIdentity: icon + "请输入正确的身份证号"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-teacher-add').serialize());
            }
        }

        $("input[name='workTime'],input[name='birthday']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $('#williamYe').on('change.bs.fileinput ', function (e) {
            // 处理自己的业务
            if(this.files[0]){
                const formData = new FormData();
                formData.append('file',this.files[0]);
                $.operate.fileUpload(formData, $('input[name="photo"]'));
            }else{
                $('input[name="photo"]').val("");
            }
        });

    </script>
</body>
</html>